from typing import Optional
from pydantic import BaseModel, Field


# 获取entid
class GetentidPayload(BaseModel):
    key: str = Field(..., description="查询关键字")
    ctype: str = Field(..., description="关键字类型（1：信用代码/注册号；2：企业全称）")


class JobApi(BaseModel):
    post_name: str = Field(None, description="招聘职位")
    post_industry: str = Field(None, description="招聘行业")
    post_release_date: str = Field(None, description="发布日期 使用$分隔")
    ent_name: str = Field(None, description="企业名称")
    ent_type: str = Field(None, description="企业类型")
    region_id: str = Field(None, description="行政区划")
    nic_id: str = Field(None, description="所属行业")
    ent_state: str = Field(None, description="企业状态")
    es_date: str = Field(None, description="开业日期 使用$分隔")
    reg_cap: str = Field(None, description="注册资金 使用$分隔")
    ent_si_num: str = Field(None, description="企业社保人数 使用$分隔")
    invse_round: str = Field(None, description="投资轮次")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")


# 应用中心详情模块入参基类
class FilterBaseModel(BaseModel):
    ent_type: str = Field(None, description="企业类型")
    region_id: str = Field(None, description="地区")
    nic_id: str = Field(None, description="行业")
    ent_state: str = Field(None, description="企业状态")
    es_date: str = Field(None, description="开业日期")
    reg_cap: str = Field(None, description="注册资本")
    ent_si_num: str = Field(None, description="企业规模")
    invse_round: str = Field(None, description="投资轮次")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")


class JobSearchApi(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    title: str = Field(None, description="招聘标题")
    post_name: str = Field(None, description="招聘职位")
    ent_industry: str = Field(None, description="招聘行业")
    release_date: str = Field(None, description="发布日期")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")


# 企业查询
class CompanySearch(BaseModel):
    basic_entname: Optional[str] = Field(None, description="公司名称")
    basic_person_name: Optional[str] = Field(None, description="人名")
    tuiguang_app: Optional[str] = Field(None, description="产品")
    website_name: Optional[str] = Field(None, description="网站")
    has_tuiguang_website: Optional[str] = Field(None, description="推广官网")
    ip_patent_patname: Optional[str] = Field(None, description="专利")
    ip_tminfo_tname: Optional[str] = Field(None, description="商标")
    bid_title: Optional[str] = Field(None, description="招标")
    basic_dom: Optional[str] = Field(None, description="企业地址")
    basic_opscope: Optional[str] = Field(None, description="经营范围")
    lianxi: Optional[str] = Field(None, description="联系方式")
    basic_uniscid: Optional[str] = Field(None, description="统一社会信用代码")
    basic_regcap: Optional[str] = Field(None, description="企业注册资金")
    basic_nicid: Optional[str] = Field(None, description="企业行业")
    basic_esdate: Optional[str] = Field(None, description="开业日期")
    basic_enttype: Optional[str] = Field(None, description="企业类型")
    basic_ygrs: Optional[str] = Field(None, description="员工/社保人数")
    basic_status: Optional[str] = Field(None, description="企业状态")
    basic_regionid: Optional[str] = Field(None, description="企业所属地区")
    jingying_vc_round: Optional[str] = Field(None, description="当前融资轮次")
    psize: Optional[str] = Field(None, description="每页数量 默认20，最大200")
    pindex: Optional[str] = Field(None, description="页码，默认0，最大翻页1000")
    sort_field: Optional[str] = Field('default', description="排序字段")
    sort_order: Optional[str] = Field('desc', description="排序顺序")
    collect_status: str = Field('0', description="领取状态 0：不限，1：未领取，2：已领取")
    revenue_assessed_status: str = Field('0', description="营收评估状态 0：不限，1：未评估，2：已评估")
    tax_assessed_status: str = Field('0', description="纳税评估状态 0：不限，1：未评估，2：已评估")
    assessed_status: str = Field('0', description="总评估状态 0：不限，1：未评估，2：已评估")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")
    corp_id: Optional[str] = Field('', description="当前企业id")
    env: Optional[str] = Field('', description="当前环境")


class XinHuaCompanySearch(BaseModel):
    ent_name: str = Field(None, description="公司名称")
    nic: str = Field(None, description="行业id")
    pageIndex: Optional[str] = Field(0, description="页码，默认0，最大翻页1000")
    pageSize: Optional[str] = Field(20, description="每页数量 默认20，最大200")


class entSearch(BaseModel):
    lianxi: Optional[str] = Field(..., description="联系方式")
    basic_entname: Optional[str] = Field('', description="公司名称")
    basic_person_name: Optional[str] = Field(..., description="人名")


class SuperApi(BaseModel):
    query: Optional[str] = Field(None, description="查询条件")
    pagesize: Optional[str] = Field('20', description="每页数量 默认20，最大200")
    pageindex: Optional[str] = Field('0', description="页码，默认0，最大翻页1000")
    sort_field: Optional[str] = Field('default', description="排序字段")
    sort_order: Optional[str] = Field('desc', description="排序顺序")
    collect_status: str = Field('0', description="领取状态 0：不限，1：当前未领取，2：当前已领取,3:历史未领取")
    revenue_assessed_status: str = Field('0', description="营收评估状态 0：不限，1：未评估，2：已评估")
    tax_assessed_status: str = Field('0', description="纳税评估状态 0：不限，1：未评估，2：已评估")
    assessed_status: str = Field('0', description="总评估状态 0：不限，1：未评估，2：已评估")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")
    corp_id: Optional[str] = Field('', description="当前企业id")
    env: Optional[str] = Field('', description="当前环境")
    contact_version: str = Field('0', description="联系方式版本 0原始版 1关联穿透版 默认0")


class QueryPush(BaseModel):
    id: Optional[str] = Field(..., description="查询条件Id")
    name: Optional[str] = Field(None, description="查询条件名称")
    parameter: Optional[str] = Field(..., description="查询条件参数")


class KeywordQuery(BaseModel):
    entids: Optional[str] = Field(..., description="企业entid，使用,分隔")
    keywordType: Optional[str] = Field(..., description="关键词类型")
    keyword: Optional[str] = Field(..., description="查询关键词")


# 企业联系方式
class LianxiPayload(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    contact_type: Optional[str] = Field('123', description="类型（1、2、3三种，1手机2座机3邮箱，全选为123，默认为123）")
    source_type: Optional[str] = Field('', description="来源")
    contact_position: str = Field(None, description="联系人职位")
    pagesize: Optional[str] = Field('50', description="每页数量 默认50")
    pageindex: Optional[str] = Field('0', description="页码，默认0")
    contact_version: str = Field('0', description="联系方式版本 0原始版 1关联穿透版 默认0")


# 关联企业联系方式
class RelateContactPayload(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    source_type: Optional[str] = Field('', description="来源")
    relate_type: str = Field(None, description="关联类型")
    pagesize: Optional[str] = Field('50', description="每页数量 默认50")
    pageindex: Optional[str] = Field('0', description="页码，默认0")


class ContactPayload(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    contact_id: str = Field(..., description="联系方式id")


# 地图拓客
class MapSearchPayload(BaseModel):
    map_type: Optional[int] = Field(..., description="画图类型: 0为多边型，1为圆形，2为地区")
    distance: Optional[str] = Field(None, description="筛选距离")
    geolocation_json: Optional[str] = Field(..., description="经纬度: json格式")

    ent_type: str = Field(None, description="企业类型")
    nic_id: str = Field(None, description="所属行业")
    ent_state: str = Field(None, description="企业状态")
    es_date: str = Field(None, description="开业日期")
    reg_cap: str = Field(None, description="注册资金")
    ent_si_num: str = Field(None, description="企业社保人数")
    invse_round: str = Field(None, description="投资轮次")

    psize: Optional[str] = Field('20', description="每页数量 默认20，最大200")
    pindex: Optional[str] = Field('0', description="页码，默认0，最大翻页1000")
    sort_field: Optional[str] = Field('default', description="排序字段")
    sort_order: Optional[str] = Field('asc', description="排序顺序")

    collect_status: str = Field('0', description="领取状态 0：不限，1：未领取，2：已领取")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")
    corp_id: Optional[str] = Field('', description="当前企业id")
    env: Optional[str] = Field('', description="当前环境")
    region_id: Optional[str] = Field('', description="区域id")
    tag_id: str = Field(None, description="企业资质标签,多个用逗号分隔")
    tag_type: str = Field(None, description="企业资质标签是交集还是并集，默认并集，1取交集")



# 新华地图拓客
class XinHuaMapSearchPayload(MapSearchPayload):
    if_claim: str = Field(None, description="是否已认领, 0:否, 1:是, ulimit:不限")
    if_authentication: str = Field(None, description="是否已认证, 0:否, 1:是, ulimit:不限")
    uid: str = Field(None, description="认领/认证企业，个人认领/认证时传此参数")


# 热力图
class HeatMapPayload(BaseModel):
    map_type: Optional[int] = Field(..., description="画图类型: 0为多边型，1为圆形,2为地区")
    distance: Optional[str] = Field(None, description="筛选距离")
    geolocation_json: Optional[str] = Field(..., description="经纬度: json格式")
    geo_hashes: Optional[int] = Field(..., description="精度：Must be between 1 and 12")

    ent_type: str = Field(None, description="企业类型")
    nic_id: str = Field(None, description="所属行业")
    ent_state: str = Field(None, description="企业状态")
    es_date: str = Field(None, description="开业日期")
    reg_cap: str = Field(None, description="注册资金")
    ent_si_num: str = Field(None, description="企业社保人数")
    invse_round: str = Field(None, description="投资轮次")
    region_id: Optional[str] = Field('', description="区域id")
    tag_id: str = Field(None, description="企业资质标签,多个用逗号分隔")
    tag_type: str = Field(None, description="企业资质标签是交集还是并集，默认并集，1取交集")



class PatentPayload(FilterBaseModel):
    patent_apply_code: str = Field(None, description="专利申请号")
    patent_name: str = Field(None, description="专利名称")
    ent_name: str = Field(None, description="企业名称")
    patent_open_date: str = Field(None, description="专利公开日期")


class PatentSearch(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    patent_apply_code: str = Field(None, description="专利申请号")
    patent_name: str = Field(None, description="专利名称")
    ent_name: str = Field(None, description="企业名称")
    patent_open_date: str = Field(None, description="专利公开日期")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")


class BaiduBiddingPayload(FilterBaseModel):
    spread_spreads: str = Field(None, description="推广关键词")
    spread_url: str = Field(None, description="推广域名")
    spread_province: str = Field(None, description="推广省份")
    ent_name: str = Field(None, description="企业名称")


class BaiduBiddingSearch(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    input_keyword: str = Field(None, description="推广关键词")
    company_url: str = Field(None, description="推广域名")
    province: str = Field(None, description="推广省份")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")


class WeChatPayload(FilterBaseModel):
    wechat_name: str = Field(None, description="微信公众号")
    ent_name: str = Field(None, description="企业名称")


class WeChatSearch(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    wechat_code: str = Field(None, description="微信公众号")
    ent_name: str = Field(None, description="企业名称")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")


# ======================================================================================================================
class TrademarkPayload(FilterBaseModel):
    trademark_name: str = Field(None, description="商标名称")
    ent_name: str = Field(None, description="企业名称")
    trademark_apply_date: str = Field(None, description="商标申请日期")


class TrademarkSearchPayload(BaseModel):
    entid: str = Field(..., description="企业唯一标识")
    trademark_name: str = Field(None, description="商标名称")
    ent_name: str = Field(None, description="企业名称")
    trademark_apply_date: str = Field(None, description="商标申请日期")
    pageindex: Optional[str] = Field('0', description="当前页码，默认0")
    pagesize: Optional[str] = Field('10', description="每页数量，默认10")


class BatchQuery(BaseModel):
    pageIndex: Optional[str] = Field(None, description="页码")
    pageSize: Optional[str] = Field(None, description="每页数量")
    entid: Optional[str] = Field(None, description="企业id加密，最多传入200个")
    entName: Optional[str] = Field(None, description="企业名称，最多传入200个")
    uniscid: Optional[str] = Field(None, description="统一社会信用代码")
    version: Optional[str] = Field('0', description="返回格式版本，默认0")
    sort_field: Optional[str] = Field('default', description="排序字段")
    sort_order: Optional[str] = Field('desc', description="排序顺序")
    collect_status: str = Field('0', description="领取状态 0：不限，1：未领取，2：已领取")
    revenue_assessed_status: str = Field('0', description="营收评估状态 0：不限，1：未评估，2：已评估")
    tax_assessed_status: str = Field('0', description="纳税评估状态 0：不限，1：未评估，2：已评估")
    assessed_status: str = Field('0', description="总评估状态 0：不限，1：未评估，2：已评估")
    corp_id: Optional[str] = Field('', description="当前企业id")
    env: Optional[str] = Field('', description="当前环境")
    contact_version: str = Field('0', description="联系方式版本 0原始版 1关联穿透版 默认0")


class BatchComplete(BaseModel):
    ent_json: str = Field(None, description='{补全主键:类型} ， 1：手机号，2：企业名称')


class EntBasePayload(BaseModel):
    case_cause: str = Field(None, description="案件案由 码表 qk_dict.code_casecause 多选 , 分隔")
    court_open_role: str = Field(None, description="开庭身份 p 原告 d被告  多选 , 分隔")
    region_id: str = Field(None, description="企业地区 多选 , 分隔")
    nic_id: Optional[str] = Field(None, description="企业行业 多选 , 分隔")
    ent_name: Optional[str] = Field(None, description="公司名称")
    reg_cap: str = Field(None, description="注册资本 范围 ,分隔")
    es_date: str = Field(None, description="企业注册时间 $ 分隔")
    if_phone: str = Field('', description="有无手机, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_landline: str = Field('', description="有无固话, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_jingxuan: str = Field('', description="有无精选, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_key_person: str = Field('', description="有无关键人, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_referral_number: str = Field('', description="有无推荐, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_open_court_placard: str = Field('', description="有无开庭公告, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_court_placard: str = Field('', description="有无法院公告, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_judgment: str = Field('', description="有无裁判文书, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_finalcase: str = Field('', description="有无终本案件, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_executed_person: str = Field('', description="有无被执行人, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_current_executed: str = Field('', description="有无当前被执行人, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_history_executed: str = Field('', description="有无历史被执行人, 1:有，0：无，ulimit:不限, 默认ulimit")
    if_apply_execute: str = Field('', description="有无申请执行人, 1:有，0：无，ulimit:不限, 默认ulimit")
    pageSize: Optional[str] = Field('20', description="每页数量 默认20")
    pageIndex: Optional[str] = Field('0', description="页码，默认0")
    sort_field: str = Field('default', description="排序字段")
    sort_order: str = Field('desc', description="排序顺序")
    corp_id: str = Field('', description="企业id")
    env: str = Field('', description="当前环境")
    collect_status: str = Field('0', description="领取状态 0：不限，1：未领取，2：已领取")

class RecentCourtOpen(EntBasePayload):
    court_open_date: str = Field(None, description="开庭日期 时间范围(起，止)使用$分隔")
    court_address: str = Field(None, description="法院地址")

class LegalAdvice(EntBasePayload):
    if_bid: str = Field(None, description="招标情况 0：不限 1：有 2:无 ")
    recruit_info: str = Field(None, description="有无法律相关岗位招聘信息 0：不限 1：有 2:无")
    bid_project_title: str = Field(None, description="招标项目")
    search_type: str = Field(None, description="招标项目搜索类型0:任一，1:不包含")

class BankruptcyReorganization(EntBasePayload):
    court_region_id: str = Field(None, description="办理法院地区id多选 , 分隔")
    bankrupt_date: str = Field(None, description="破产日期范围 ,分隔")

class CreditRepair(EntBasePayload):
    repair_type: str = Field(None, description="修复类型多选  ,分隔")
    recent_case_time: str = Field(None, description="最近立案时间")
    court_region_id: str = Field(None, description="办理法院地区id多选 , 分隔")

class FinancialService(BaseModel):
    region_id: str = Field(None, description="企业地区 多选 , 分隔")
    nic_id: Optional[str] = Field(None, description="企业行业 多选 , 分隔")
    reg_cap: str = Field(None, description="注册资本 范围 ,分隔")
    es_date: str = Field(None, description="企业注册时间")
    AnnualTaxAmount: str = Field(None, description="年纳税金额")
    AnnualRevenueAmount: str = Field(None, description="年营收金额")
    ClassATax: str = Field(None, description="是否为A级纳税人 0 否 1 是")
    contact_type: str = Field(None, description="联系方式类型， 55：手机， 56：固话， 58：精选 if_key_person：关键人 if_referral_number：推荐")
    risk_info: str = Field(None,
                           description="联系方式类型， 2：开庭公告， 3：法院公告， 1：裁判文书 if_finalcase：终本案件 4：被执行人 if_current_executed：当前被执行人 if_history_executed：历史被执行人 if_apply_execute：申请执行人")
    ent_nic: str = Field(None, description="金融服务-行业类型（除去税票贷、中标贷） 科技贷：'I'  抵押贷：'K' 制造业：'C' 建筑工程：'E' 批发零售：'F' 农林牧渔：'A' ")
    pageSize: Optional[str] = Field('20', description="每页数量 默认20")
    pageIndex: Optional[str] = Field('1', description="页码，默认0")

class BankContactService(BaseModel):
    credit_code: str = Field(..., description="统一信用代码")
